#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;

namespace Osh.Dvb
{
	/// <summary>
	/// Summary description for EitEvent.
	/// </summary>
	public class EitEvent
	{
		private ushort _eventId;
		private DateTime _startTime;
		private TimeSpan _duration;
		private int _descriptorsLoopLength;
		private IDescriptor[] _descriptors;

		public EitEvent(EitReader reader)
		{
			_eventId = reader.ReadUInt16BE();
			_startTime = reader.ReadDateTime();
			_duration = reader.ReadTimeSpan();

			_descriptorsLoopLength = reader.ReadUInt16BE() & 0xFFF;
			_descriptors = reader.DescriptorReader.ReadDescriptors(_descriptorsLoopLength, true);
		}

		public ushort EventId
		{
			get { return _eventId; }
		}
		public DateTime StartTime
		{
			get { return _startTime; }
		}
		public TimeSpan Duration
		{
			get { return _duration; }
		}
		public int Length
		{
			get { return HeaderLength + BodyLength; }
		}
		public int HeaderLength
		{
			get { return 12; }
		}
		public int BodyLength
		{
			get { return _descriptorsLoopLength; }
		}
		public IDescriptor[] Descriptors
		{
			get { return _descriptors; }
		}
	}
}


